﻿using System.Collections.Generic;
using System.Linq;
using ETModel;

namespace ETHotfix {
    [ObjectSystem]
    public class MapPlayersComponentAwakeSystem : AwakeSystem<MapPlayersComponent> {
        public override void Awake(MapPlayersComponent self) {
            self.Awake();
        }
    }
    /// <summary>
    /// map服务器的玩家管理,热更层框架会自动加到场景<para/>
    /// Gate玩家彻底断开连接,Map玩家会自动销毁<para/>
    /// </summary>
    public class MapPlayersComponent : BaseEntityMgrComponent<MapPlayer> {
        /// <summary>
        /// 根据gate玩家实例ID,获取已存在的map玩家对象
        /// </summary>
        /// <param name="gatePlayerInsId"></param>
        /// <returns></returns>
        public MapPlayer GetMapPlayerByGatePlayerInsId(long gatePlayerInsId) {
            return idPlayers.Values.FirstOrDefault(p => p.GetObj()?.GateClientActorId == gatePlayerInsId).GetObj();
        }
    }
}